package com.voice.server.command.impl;

import com.voice.server.command.DeviceCommand;
import com.voice.server.connection.ConnectionInvoke;
import com.voice.server.message.sdk.DeviceTextMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.net.URL;

@Component
public class AudioUrlCommand implements DeviceCommand<URL> {

    private String topic="/device/url";
    @Autowired
    private ConnectionInvoke connectionInvoke;

    @Override
    public void execute(String userId, String deviceKey, URL url) {
        DeviceTextMessage deviceTextMessage=new DeviceTextMessage(userId,deviceKey,url.toString());
        connectionInvoke.sendDeviceMessage(deviceKey,topic,deviceTextMessage);
    }

}
